local Config = require("Config")
local Json = require("common.Json")
local Lang = require("common.Lang")
local Msg = require("core.Msg")
local Timer = require("core.Timer")
local Broadcast = require("broadcast.Broadcast")

REPORT_BUG_PHP = "/qqapi/report_bug.php?a="

function bugReport(human, type, title, content)
	print("bugReport, type", type,title, content)

	if human.bugReportTime and human.bugReportTime + 60000 > Timer.now then
		return Broadcast.sendDown(human, Lang.CHAT_BUG_REPORT_TIME_SHORT)		
	end

	human.bugReportTime = Timer.now

    local s2aParam = {}    
    s2aParam.sid = Config.SVR_INDEX
    s2aParam.account_name = human.db.account
    s2aParam.role_name = human.db.name
    s2aParam.title = title
    s2aParam.content = content
    s2aParam.type = type
    s2aParam.op = "bug"
     
	_G.thread_http.send(REPORT_BUG_PHP,Json.Encode(s2aParam))

	Broadcast.sendDown(human, Lang.UNION_SEND_SUCCESS)		

	Msg.send(Msg.gc.GC_BUG_REPORT, human.fd)
end

function jubao(human, targetUuid, targetName, code)
	print("jubao, type", code, targetUuid, targetName)
	
	if human.bugReportTime and human.bugReportTime + 60000 > Timer.now then
		return Broadcast.sendDown(human, Lang.CHAT_BUG_REPORT_TIME_SHORT)		
	end
	
	human.bugReportTime = Timer.now

    local s2aParam = {}    
    s2aParam.sid = Config.SVR_INDEX
    s2aParam.account_name = human.db.account
    s2aParam.role_name = human.db.name
    s2aParam.targetUuid = targetUuid
    s2aParam.targetName = targetName
    s2aParam.code = code
    s2aParam.op = "jubao"
     
	_G.thread_http.send(REPORT_BUG_PHP,Json.Encode(s2aParam))

	Broadcast.sendDown(human, Lang.UNION_SEND_SUCCESS)		

	Msg.send(Msg.gc.GC_PLAYER_JUBAO, human.fd)
end